jQuery(document).ready(function($){
    $(document).on('submit', '.deepseek-ai-password-form', function(e){
        e.preventDefault();
        var $form = $(this);
        var post_id = $form.data('post-id');
        var password = $form.find('input[name="password"]').val();
        var $error = $form.find('.deepseek-ai-password-error');
        $error.hide();
        if (!password) {
            $error.text('请输入密码').show();
            return;
        }
        $.post(DeepSeekAIPassword.ajax_url, {
            action: 'deepseek_ai_check_password',
            nonce: DeepSeekAIPassword.nonce,
            post_id: post_id,
            password: password
        }, function(resp){
            if (resp.success) {
                location.reload();
            } else {
                $error.text(resp.data && resp.data.msg ? resp.data.msg : DeepSeekAIPassword.error_msg).show();
            }
        });
    });
}); 